/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef __NOISE_HARD_ANDROID_HARDWARE_H__
#define __NOISE_HARD_ANDROID_HARDWARE_H__

#include <noise/hard/Hardware.h>
#include <threads/Thread.h>
#include <threads/Lock.h>
#include <math/Vector3.h>
#include "Channel.h"

namespace liba
{
namespace noise
{
namespace hard
{
namespace android
{

class Hardware : public hard::Hardware
{
public:
	Hardware();
	virtual ~Hardware();
	
	virtual hard::Channel * create_static_channel( const Atom & channel_type, const filesystem::String & name);
	virtual hard::Channel * create_streaming_channel( const Atom & channel_type );
	
	virtual std::string get_name()const
	{
		return std::string("android");
	}

	void life_cycle( double delta_time );

	void play_static_3d_channel(ChannelStatic * channel)
	{
		playing_channels.push_back(channel);
	}
	void stop_static_3d_channel(ChannelStatic * channel)
	{
		playing_channels.remove(channel);
	}
	
	void add_static_channel(ChannelStatic * channel)
	{
		static_channels.push_back(channel);
	}
	void remove_static_channel(ChannelStatic * channel)
	{
		static_channels.remove(channel);
	}
	
protected:
	virtual bool change_attribute(const Atom & name, const math::Vector3<float> & value);
	virtual bool change_attribute(const Atom & name, double value);
	virtual bool change_attribute(const Atom & name, const Atom & value);
	virtual bool get_attribute(const Atom & name, math::Vector3<float> * value)const;
	virtual bool get_attribute(const Atom & name, double * value)const;
private:
	typedef std::list<ChannelStatic *> ChannelStaticList;
	ChannelStaticList playing_channels;
	ChannelStaticList static_channels;
	
	int max_playing_channels;
	math::Vector3<float> listener_front, listener_up;
	math::Vector3<float> listener_position, listener_speed;

	double exact_volume;
};

} // namespace android
} // namespace hard
} // namespace noise
} // namesapce liba
using namespace liba;

#endif // __NOISE_HARD_openal_HARDWARE_H__

